package com.fj.netty.bytebuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

/**
 * @author fj
 * @date 2024/1/8 11:22
 */
public class TestByteBufGetSet {
    public static void main(String[] args) {
        ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(6);
        byteBuf.setBoolean(0,false);
        byteBuf.setByte(1,'a');
        byteBuf.setShort(2,1);
//        byteBuf.setInt(3,Integer.MAX_VALUE);
        byteBuf.setBytes(3,new byte[]{1,2});
        System.out.println(byteBuf.getBoolean(0));
        System.out.println(byteBuf.getByte(1));
        System.out.println(byteBuf.getShort(2));
//        System.out.println(byteBuf.getLong(2));
        byte[] dest = new byte[2];
        System.out.println(byteBuf.getBytes(3, dest));
        for (int i = 0; i < dest.length; i++) {
            System.out.println(dest[i]);
        }
//        System.out.println(Byte.MAX_VALUE);
//        System.out.println(Short.MAX_VALUE);
//        System.out.println(Integer.MAX_VALUE);
//        System.out.println(Long.MAX_VALUE);
    }
}
